package br.com.actionsystem.gdp.telas;

import br.com.actionsystem.gdp.modelo.Usuario;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JInternalFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

public class JfmPrincipal extends javax.swing.JFrame {
    private About about = null;
    private JInternalFrame receitasFm = null;
    private JInternalFrame despesasFm = null;
    private JInternalFrame pagamentosFm = null;
    private JInternalFrame reservasFm = null;
    private JInternalFrame calendarFm = null;
    private JInternalFrame relatorioFm = null;
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");

    public JfmPrincipal(Usuario u) {
        super("Gerenciador de Despesas Pessoais");
        try {
            UIManager.setLookAndFeel("com.jtattoo.plaf.mcwin.McWinLookAndFeel");
            SwingUtilities.updateComponentTreeUI(this);
        } catch (Exception e) {
        }
        initComponents();
        jLabel1.setText("Usuário: "+u.getNome());
        jLabel2.setText("Data: "+df.format(new Date()));
        Calculadora.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    Runtime.getRuntime().exec("calc");
                } catch (IOException ex) {
                   ex.printStackTrace();
                }
            }
        });
        Calendario.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if(calendarFm == null){
                calendarFm = new JfmCalendario();
                jDesktopPane.add(calendarFm);
                }
                calendarFm.setVisible(true);
            }
        });
        Relatórios.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                 getRelatorioFm();
            }
        });

        GerenciarReservas.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                getReservasFm();
            }
        });
    }

    private void getReceitasFm() {
        if (receitasFm == null) {
            receitasFm = new Receitas();
            jDesktopPane.add(receitasFm);

        }
        receitasFm.setVisible(true);

    }

    private void getPagamentoFm() {
        if (pagamentosFm == null) {
            pagamentosFm = new Pagamentos();
            jDesktopPane.add(pagamentosFm);
        }
        pagamentosFm.setVisible(true);
    }

    private void getReservasFm() {
        if (reservasFm == null) {
            reservasFm = new JfmReservas();
            jDesktopPane.add(reservasFm);
        }
        reservasFm.setVisible(true);
    }

    private void getDespesasFm() {
        if (despesasFm == null) {
            despesasFm = new Despesas();
            jDesktopPane.add(despesasFm);
        }
        despesasFm.setVisible(true);
    }

      private void getRelatorioFm() {
        if (relatorioFm == null) {
            relatorioFm = new JfmRelatorio();
            jDesktopPane.add(relatorioFm);
        }
        relatorioFm.setVisible(true);
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jDesktopPane = new javax.swing.JDesktopPane();
        PainelColor = new javax.swing.JPanel();
        Receita = new javax.swing.JButton();
        Despesas = new javax.swing.JButton();
        Reservas = new javax.swing.JButton();
        Pagamento = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        Calculadora = new javax.swing.JButton();
        GerenciarReservas = new javax.swing.JButton();
        GerenciarDespesas = new javax.swing.JButton();
        GerenciarReceita = new javax.swing.JButton();
        Relatórios = new javax.swing.JButton();
        pagamentos = new javax.swing.JButton();
        Calendario = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        PainelColor.setBackground(new java.awt.Color(159, 234, 251));
        PainelColor.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Ações Principais", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial Black", 0, 11))); // NOI18N

        Receita.setFont(new java.awt.Font("Verdana", 1, 18));
        Receita.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icon001.png"))); // NOI18N
        Receita.setText("Receitas");
        Receita.setToolTipText("Gerenciar Receitas");
        Receita.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Receita.setIconTextGap(0);
        Receita.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        Receita.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        Receita.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ReceitaActionPerformed(evt);
            }
        });

        Despesas.setFont(new java.awt.Font("Verdana", 1, 18)); // NOI18N
        Despesas.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icon013.png"))); // NOI18N
        Despesas.setText("Despesas");
        Despesas.setToolTipText("Gerenciar Despesas");
        Despesas.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Despesas.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        Despesas.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        Despesas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DespesasActionPerformed(evt);
            }
        });

        Reservas.setFont(new java.awt.Font("Verdana", 1, 18)); // NOI18N
        Reservas.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icon029.png"))); // NOI18N
        Reservas.setText("Reservas");
        Reservas.setToolTipText("Gerenciar Reservas");
        Reservas.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Reservas.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        Reservas.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        Reservas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ReservasActionPerformed(evt);
            }
        });

        Pagamento.setFont(new java.awt.Font("Verdana", 1, 18)); // NOI18N
        Pagamento.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icon030.png"))); // NOI18N
        Pagamento.setText("Pagamentos");
        Pagamento.setToolTipText("Efetuar pagamento de despesas e recebimento de receitas");
        Pagamento.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Pagamento.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        Pagamento.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        Pagamento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PagamentoActionPerformed(evt);
            }
        });

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/about-us.png"))); // NOI18N
        jButton1.setToolTipText("Informações sobre o produto");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout PainelColorLayout = new javax.swing.GroupLayout(PainelColor);
        PainelColor.setLayout(PainelColorLayout);
        PainelColorLayout.setHorizontalGroup(
            PainelColorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PainelColorLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PainelColorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(Reservas, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Receita, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 135, Short.MAX_VALUE)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(122, 122, 122)
                .addGroup(PainelColorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(Pagamento, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Despesas, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        PainelColorLayout.setVerticalGroup(
            PainelColorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PainelColorLayout.createSequentialGroup()
                .addGroup(PainelColorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(Despesas)
                    .addComponent(Receita))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(PainelColorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(Pagamento, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(Reservas, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
            .addGroup(PainelColorLayout.createSequentialGroup()
                .addGap(126, 126, 126)
                .addComponent(jButton1)
                .addContainerGap(134, Short.MAX_VALUE))
        );

        PainelColor.setBounds(10, 150, 850, 376);
        jDesktopPane.add(PainelColor, javax.swing.JLayeredPane.DEFAULT_LAYER);
        PainelColor.getAccessibleContext().setAccessibleName("Principais Ações");

        jPanel2.setBackground(new java.awt.Color(230, 237, 244));
        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel1.setFont(new java.awt.Font("Arial Black", 0, 14));
        jLabel1.setText("Usuário: ");

        jLabel2.setFont(new java.awt.Font("Arial Black", 0, 14));
        jLabel2.setText("Data: ");

        Calculadora.setFont(new java.awt.Font("Verdana", 1, 12));
        Calculadora.setText("Calculadora");
        Calculadora.setFocusable(false);
        Calculadora.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Calculadora.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        GerenciarReservas.setFont(new java.awt.Font("Verdana", 1, 12));
        GerenciarReservas.setText("Gerenciar Reservas");
        GerenciarReservas.setFocusable(false);
        GerenciarReservas.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        GerenciarReservas.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        GerenciarDespesas.setFont(new java.awt.Font("Verdana", 1, 12));
        GerenciarDespesas.setText("Gerenciar Despesas");
        GerenciarDespesas.setFocusable(false);
        GerenciarDespesas.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        GerenciarDespesas.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        GerenciarDespesas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                GerenciarDespesasActionPerformed(evt);
            }
        });

        GerenciarReceita.setFont(new java.awt.Font("Verdana", 1, 12));
        GerenciarReceita.setText("Gerenciar Receita");
        GerenciarReceita.setFocusable(false);
        GerenciarReceita.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        GerenciarReceita.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        GerenciarReceita.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                GerenciarReceitaActionPerformed(evt);
            }
        });

        Relatórios.setFont(new java.awt.Font("Verdana", 1, 12));
        Relatórios.setText("Relatórios");
        Relatórios.setFocusable(false);
        Relatórios.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Relatórios.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        pagamentos.setFont(new java.awt.Font("Verdana", 1, 12));
        pagamentos.setText("Pagamentos");
        pagamentos.setFocusable(false);
        pagamentos.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        pagamentos.setPreferredSize(new java.awt.Dimension(47, 21));
        pagamentos.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        pagamentos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pagamentosActionPerformed(evt);
            }
        });

        Calendario.setFont(new java.awt.Font("Verdana", 1, 12));
        Calendario.setText("Calendario");
        Calendario.setFocusable(false);
        Calendario.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Calendario.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(253, 253, 253)
                        .addComponent(jLabel2))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(pagamentos, javax.swing.GroupLayout.DEFAULT_SIZE, 249, Short.MAX_VALUE)
                            .addComponent(GerenciarDespesas, javax.swing.GroupLayout.DEFAULT_SIZE, 249, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(GerenciarReservas, javax.swing.GroupLayout.DEFAULT_SIZE, 247, Short.MAX_VALUE)
                            .addComponent(GerenciarReceita, javax.swing.GroupLayout.DEFAULT_SIZE, 247, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                                .addComponent(Calendario, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(Calculadora, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(Relatórios, javax.swing.GroupLayout.DEFAULT_SIZE, 318, Short.MAX_VALUE))))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(GerenciarReceita, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Relatórios, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(GerenciarDespesas, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Calculadora, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(GerenciarReservas, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pagamentos, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Calendario, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanel2.setBounds(10, 10, 850, 120);
        jDesktopPane.add(jPanel2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jDesktopPane, javax.swing.GroupLayout.PREFERRED_SIZE, 870, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jDesktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 559, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void ReceitaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ReceitaActionPerformed
        getReceitasFm();
    }//GEN-LAST:event_ReceitaActionPerformed

    private void DespesasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DespesasActionPerformed
        getDespesasFm();
    }//GEN-LAST:event_DespesasActionPerformed

    private void ReservasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ReservasActionPerformed
        getReservasFm();

    }//GEN-LAST:event_ReservasActionPerformed

    private void PagamentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PagamentoActionPerformed
        getPagamentoFm();
    }//GEN-LAST:event_PagamentoActionPerformed

    private void GerenciarReceitaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GerenciarReceitaActionPerformed
        getReceitasFm();
    }//GEN-LAST:event_GerenciarReceitaActionPerformed

    private void pagamentosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pagamentosActionPerformed
       getPagamentoFm();
}//GEN-LAST:event_pagamentosActionPerformed

    private void GerenciarDespesasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GerenciarDespesasActionPerformed
        getDespesasFm();
    }//GEN-LAST:event_GerenciarDespesasActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        if(about == null){
            about = new About();
            jDesktopPane.add(about);
        }
        about.setVisible(true);
    }//GEN-LAST:event_jButton1ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Calculadora;
    private javax.swing.JButton Calendario;
    private javax.swing.JButton Despesas;
    private javax.swing.JButton GerenciarDespesas;
    private javax.swing.JButton GerenciarReceita;
    private javax.swing.JButton GerenciarReservas;
    private javax.swing.JButton Pagamento;
    private javax.swing.JPanel PainelColor;
    private javax.swing.JButton Receita;
    private javax.swing.JButton Relatórios;
    private javax.swing.JButton Reservas;
    private javax.swing.JButton jButton1;
    private javax.swing.JDesktopPane jDesktopPane;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JButton pagamentos;
    // End of variables declaration//GEN-END:variables
}
